/*
 * MixerMissionManager.h
 *
 *  Created on: Nov 28, 2013
 *      Author: wyf
 */

#ifndef MIXERMISSIONMANAGER_H_
#define MIXERMISSIONMANAGER_H_

#include <map>
#include <stddef.h>
#include "ctType.h"
#include "ctRWLock.h"

#include "MixerMission.h"
#include "ctSingleton.h"
#include "UDPPacket.h"

class MixerMissionManager: public Singleton<MixerMissionManager> {
	public:
		MixerMissionManager();
		virtual ~MixerMissionManager();

	public:
		void onAudioPacket(uint8_t* buf, DWORD len);
		void disPatchPacket(DWORD roomid, UDPPacket* pack);
		void getAudioPacket(t_BufferCmdQueue &to);
	public:
		bool addRecMission(DWORD roomid, DWORD recid, DWORD sttime, DWORD endtime, const char *path);
		void delRecMission(DWORD roomid);
		void updateRecTime(DWORD roomid, DWORD sttime, DWORD endtime);
		void delTimeOutMission(DWORD curtime);

		void memberLeaveFromRoom(DWORD roomid, DWORD userid);
		void memberJoinRoom(DWORD roomid, DWORD userid);
		void addMuteData(const uint8_t *data, const DWORD &len);

	private:
		typedef std::map<DWORD, MixerMission *> MissionMap;
		typedef MissionMap::iterator TM_IT;
		typedef MissionMap::const_iterator TM_CIT;
		typedef MissionMap::value_type TM_VT;
		MissionMap mission_map_;

		ctRWLock rwlock_;
};

#endif /* MIXERMISSIONMANAGER_H_ */

